/******************************************************************************
* Copyright (C), 2016-2019, MYIR
* FileName: common.h 
* Author: Joshua
* Version: 1.0
* Date: 2019�� 02�� 14�� 
* Description: Common definition         
*
* History:        
*  <author>  	<time>   	<version >   	<desc>
*  Joshua   	14/02/2019      1.0     	create this moudle  
*                                                                          
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*******************************************************************************/

#ifndef __EVADA_COMMON_H__
#define __EVADA_COMMON_H__
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <pthread.h>
#include <sys/epoll.h>
#include <poll.h>
#define SOCKET_PATH "/tmp/socket_msg"
enum {
    IPC_START,
    MODBUS_IPC,
    IPC_END
};

typedef struct {
    int type;
    int length;
    char value[];
}ipc_common;

typedef struct {
    int type;
    int length;
    char value[];
}IPC_common;

typedef void *(*socket_recv_handler)(void *param);

extern void quit_signal_init(void);
extern int is_exit(void);
extern int server_socket_init(void);
extern int client_socket_init(void);
extern int server_socket_connect(int socket_fd);
extern int socket_send_msg(int socket_fd, char *buff, unsigned int len);
extern int socket_recv_thread(pthread_t *thread_id, int socket_fd);
extern int socketfd_bind(int type, int socket_fd);
extern void socketfd_unbind(int type);
extern int send_TLV_data(int type, void *data, int len);
extern int get_TLV_data(int type, void *data, int len);
#endif
